<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="card">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input
            placeholder="请输入搜索内容"
            class="input-with-select"
            clearable
          >
            <el-button slot="append" icon="el-icon-search"> </el-button>
          </el-input>
        </el-col>
        <el-col :span="4">
          <!-- 添加用户按钮 -->
          <el-button
            type="primary"
            class="butt_tian"
            @click="addDialogVisible = true"
            >添加角色</el-button
          >
        </el-col>
      </el-row>
      <el-table :data="rolesList" stripe border>
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="权限列表">
                <span>{{ props.row.name }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column type="index" label="#"> </el-table-column>
        <el-table-column prop="roleName" label="角色名称"> </el-table-column>
        <el-table-column prop="roleDesc" label="角色描述"> </el-table-column>
        <el-table-column label="操作" width="340px">
          <template>
            <el-button type="primary" icon="el-icon-edit">编辑</el-button>
            <el-button type="danger" icon="el-icon-delete">删除</el-button>
            <el-button type="warning" icon="el-icon-setting"
              >分配权限</el-button
            ></template
          >
        </el-table-column>
      </el-table>
      <!-- 分页区域 -->
    </el-card>
    <!-- 添加用户的对话框 -->
    <el-dialog
      title="添加角色信息"
      :visible.sync="addDialogVisible"
      width="50%"
    >
      <!-- 内容主体区域 -->
      <el-form
        :model="addForm"
        :rules="addFormRules"
        ref="addFormRef"
        label-width="80px"
      >
        <el-form-item label="角色名称" prop="roleName">
          <el-input v-model="addForm.roleName"></el-input>
        </el-form-item>
        <el-form-item label="角色描述" prop="roleDesc">
          <el-input v-model="addForm.roleDesc"></el-input>
        </el-form-item>
      </el-form>
      <!-- 底部按钮区域 -->
      <span slot="footer" class="dialog-footer">
        <el-button @click="addDialogVisible = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      total: 0,
      rolesList: [
        {
          roleName: '测试角色_用户',
          roleDesc: '测试用户管理功能时使用',
        },
        {
          roleName: '超级管理员',
          roleDesc: '拥有最高权限',
        },
        {
          roleName: '管理员',
          roleDesc: '拥有部分权限',
        },
        {
          roleName: '测试角色_权限',
          roleDesc: '测试权限管理功能时使用',
        },
        {
          roleName: '测试角色_商品',
          roleDesc: '测试商品管理功能时使用',
        },
        {
          roleName: '测试角色_订单',
          roleDesc: '测试订单管理功能时使用',
        },
      ],
      addDialogVisible: false,
      addForm: {
        roleName: '',
        roleDesc: '',
      },
      addFormRules: {
        roleName: [
          { required: true, message: '请输入角色名称', trigger: 'blur' },
        ],
        roleDesc: [{ message: '请输入角色描述', trigger: 'blur' }],
      },
    }
  },
}
</script>

<style lang="less" scoped>
.butt_tian {
  margin-bottom: 15px;
}
.card {
  margin-top: 20px;
}
</style>
